import java.util.Arrays;

public class demo1 {
    public static void main(String[] args) {
      int []arr={1,2,3,4,5,6,7};
      twosum(arr,5);
        System.out.println(Arrays.toString(twosum(arr,5)));
    }
    public static int[] twosum(int[]arr,int target){
        int [] result=new int[2];
        for (int i = 0; i < arr.length-1 ; i++) {
            for (int j =arr.length-1; j >i; j--) {
            if(arr[i]+arr[j]==target){
                result[0]=i;
                result[1]=j;
            }
            }

        }
        return result;
    }
}
